package com.ITArmy.controller;

import com.ITArmy.beans.Shows.PraiseMessage;
import com.ITArmy.common.ServerResponse;
import com.ITArmy.controller.base.BaseController;
import com.ITArmy.service.PraiseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Api(value = "点赞接口", tags = "点赞接口PraiseController")
@RequestMapping("/praise")
@Controller
public class PraiseController extends BaseController {

    /**
     * 用户点赞博客
     */
    @RequestMapping("/likeBlog")
    @ApiOperation(value = "用户点赞博客", notes = "需要博客的id",
            httpMethod = "POST", response = ServerResponse.class)
    @ResponseBody
    public ServerResponse likeBlog(HttpServletRequest req, long blogId) {
        return praiseService.likeBlog(req, blogId);
    }

    @RequestMapping("/likeComment")
    @ApiOperation(value = "用户给评论点赞", notes = "需要这条评论的id",
            httpMethod = "POST", response = ServerResponse.class)
    @ResponseBody
    public ServerResponse likeComment(HttpServletRequest request, int commentId) {
        return praiseService.likeComment(request, commentId);
    }

    @RequestMapping("/unlikeComment")
    @ApiOperation(value = "用户取消点赞评论", notes = "需要这条评论的id",
            httpMethod = "POST", response = ServerResponse.class)
    @ResponseBody
    public ServerResponse unlikeComment(long cid) {
        return praiseService.unlikeComment(cid);
    }

    @RequestMapping("/unlikeBlog")
    @ApiOperation(value = "用户取消点赞博客", notes = "需要这条博客的id",
            httpMethod = "POST", response = ServerResponse.class)
    @ResponseBody
    public ServerResponse unlikeBlog(long bid) {
        return praiseService.unlikeBlog(bid);
    }


//    @RequestMapping("/informationAgreePage")
//    @ApiOperation(value = "进入消息点赞页面", httpMethod = "GET")
//    public String informationAgreePage(HttpServletRequest request, Model model) {
//        List<PraiseMessage> praiseMessages=messageService.getPrise(request);
//        model.addAttribute("praiseMessages",praiseMessages);
//        return "informationAgree";
//    }

}
